package com.tanhua.manage.controller;


import com.tanhua.manage.service.VideoService;
import com.tanhua.manage.vo.PageResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("management/manage")
@Slf4j
public class VideoController {

    @Autowired
    private VideoService videoService;

    @GetMapping("videos")
    public ResponseEntity<PageResult> queryVideoList(
            @RequestParam("pagesize") String pageSize,
            @RequestParam("page") String page,
            @RequestParam("sortProp") String sortProp,
            @RequestParam("sortOrder") String sortOrder,
            @RequestParam("uid") String uid) {
        try {
            PageResult pageResult = this.videoService.queryVideoList(pageSize, page, sortProp, sortOrder, uid);
            if (pageResult != null) {
                return ResponseEntity.ok(pageResult);
            }
        } catch (Exception e) {
            log.error("查询视频翻页失败");
            e.printStackTrace();
        }
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
    }
}
